package com.shadow.mall.customer.remote.dubbo;

import com.shadow.mall.common.core.JsonResult;
import com.shadow.mall.customer.domain.request.CustomerReceiveAfterSaleRequest;
import com.shadow.mall.customer.domain.request.CustomerReviewReturnGoodsRequest;
import com.shadow.mall.customer.exception.CustomerBizException;
import com.shadow.mall.order.api.AfterSaleApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 订单售后远程接口
 *
 *
 * @version 1.0
 */
public class AfterSaleRemote {

    @Autowired
    private AfterSaleApi afterSaleApi;

    /**
     * 接收客服的审核结果
     */
    public JsonResult<Boolean> receiveCustomerAuditResult(CustomerReviewReturnGoodsRequest customerReviewReturnGoodsRequest) {
        JsonResult<Boolean> jsonResult = afterSaleApi.receiveCustomerAuditResult(customerReviewReturnGoodsRequest);
        if (!jsonResult.getSuccess()) {
            throw new CustomerBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
        return jsonResult;
    }

    /**
     * 客服系统查询售后支付单信息
     */
    public JsonResult<Long> customerFindAfterSaleRefundInfo(CustomerReceiveAfterSaleRequest customerReceiveAfterSaleRequest) {
        JsonResult<Long> jsonResult = afterSaleApi.customerFindAfterSaleRefundInfo(customerReceiveAfterSaleRequest);
        if (!jsonResult.getSuccess()) {
            throw new CustomerBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
        return jsonResult;
    }
}
